home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14829 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: siemens.at!david
  2. From: david@ws2309.gud.siemens.co.at (Hr.McCann)
  3. Newsgroups: comp.lang.c++,comp.sys.hp.hpux
  4. Subject: Re: Problem combining signal() with exceptions on HP-UX (ugh!)
  5. Followup-To: comp.lang.c++,comp.sys.hp.hpux
  6. Date: 2 Apr 1996 07:08:06 GMT
  7. Organization: Siemens AG Austria
  8. Message-ID: <4jqjom$99u@news.siemens.at>
  9. References: <4iohb5$e9i@gossamer.itmel.bhp.com.au>
  10. Reply-To: David.McCann@siemens.co.at
  11. NNTP-Posting-Host: ws2309.gud.siemens-austria
  12. X-Newsreader: TIN [version 1.1 PL8]
  13.  
  14. Chris Kuan (kuan.chris.ch@bhp.com.au) wrote:
  15.  
  16. > I'm running HP CC on HP-UX 9, and trying to catch signals and turn them
  17. > into exceptions.
  18.  
  19. > Question : how can I get signalling and exception handling to work consistently?
  20. >  - and don't say, "Don't do it." It's beyond my control as to WHY this is 
  21. > necessary :-( 
  22.  
  23. Don't do it :-). Really. Exceptions are not designed to cope with asynchronous
  24. events like external signals. If you read almost any literature on the subject,
  25. you should know this. Your design is wrong.
  26.  
  27. That said, if you really really really must turn signals into exceptions, then
  28. the only clean way I can think of is to set some global flag in a signal handler
  29. to say 'signal occurred' and then return. However, your program code then has to
  30. poll this flag at appropriate intervals (ouch!).
  31.  
  32. Furthermore, this approach wouldn't work for signals like SIGSEGV, because you'd
  33. be resuming execution from the statement that caused the signal to be raised,
  34. with undefined results (probably another SIGSEGV, causing an endless loop! I've
  35. seen this happen many times before now!).
  36.  
  37. If you're still hell-bent on this approach, then good luck. You'll need it :-(
  38.  
  39. David.
  40.  
  41. =====================================================================
  42. David McCann                    | MAIL: David.McCann@siemens.co.at
  43. PSE TMN 23                      |
  44. Siemens AG Austria              | VOICE: +43 1 1707-45606
  45. Gudrunstrasse 11                | FAX:   +43 1 1707-55712
  46. A-1101 Wien                     | Broker FAQ: http://mx2310/Broker/
  47. =====================================================================
  48.